from configparser import *
from config_reader import *
from tool import *
from os import startfile

class Check:
    def __init__(self):
        self.truth_ans = reader().truth_ans
        self.user_ans = reader().user_ans
        self.true = 0
        self.contant = ""

        pass

    def main(self):
        with open("./反馈.txt","w")as f:
            for i in self.truth_ans:
                if(self.user_ans[self.truth_ans.index(i)] == i):
                    self.true += 1
                    self.contant += "{0} √\n".format(i)
                else:
                    self.contant += "{0} X => {1}\n".format(self.user_ans[self.truth_ans.index(i)],i)
            f.write("一共: {0}\n"
                    "错误: {1}\n"
                    "正确率: {2}\n"
                    "=========结界=========\n".format(len(self.truth_ans),len(self.truth_ans) - self.true,self.true * 1.0 / len(self.truth_ans)))
            f.write(self.contant)
        startfile("反馈.txt")

        return "face"



        pass